
    $(function () {
        var flagName = true;
        var flagApart = true;
        var nameForm, apartForm;
        $("#registerusername").change(function () {
            nameForm = $("#registerusername").val();
            if (nameForm == "") {
                $("#registerusername").removeClass("form-control is-valid")
                $("#registerusername").addClass("form-control is-invalid");
                flagName = false;
            } else {
                $("#registerusername").removeClass("form-control is-invalid")
                $("#registerusername").addClass("form-control is-valid");
                flagName = true;
            }
        })
        $("#registerapartment").change(function () {
            apartForm = $("#registerapartment").val();
            if (apartForm == "") {
                $("#registerapartment").removeClass("form-control is-valid")
                $("#registerapartment").addClass("form-control is-invalid");
                flagApart = false;
            } else {
                $("#registerapartment").removeClass("form-control is-invalid")
                $("#registerapartment").addClass("form-control is-valid");
                flagApart = true;
            }
        })
        $("#register").click(function () {
            if (flagName && flagApart) {
                return true;
            } else {
                if (!flagName) {
                    $("#registerusername").addClass("form-control is-invalid");
                }
                if (!flagApart) {
                    $("#registerapartment").addClass("form-control is-invalid");
                }
                return false;
            }
        })
    })